package com.sxau.software_educational_system_backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sxau.software_educational_system_backend.domain.entity.Content;
import com.sxau.software_educational_system_backend.service.ContentService;
import com.sxau.software_educational_system_backend.mapper.ContentMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
* @author mi
* @description 针对表【content】的数据库操作Service实现
* @createDate 2025-05-07 20:35:58
*/
@Service
public class ContentServiceImpl extends ServiceImpl<ContentMapper, Content>
    implements ContentService{

    @Resource
    private ContentMapper contentMapper;


    @Override
    public Page<Content> pageByType(Page<Content> page, String type) {

        QueryWrapper<Content> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type", type);
        return contentMapper.selectPage(page, queryWrapper);
    }

    @Override
    public List<Content> getByType(String type) {
        QueryWrapper<Content> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type", type);
        List<Content> contents = contentMapper.selectList(queryWrapper);
        return contents;
    }
}




